#include "randomgenerateclass.h"

#include <QElapsedTimer>

#include <vector>
#include <random>
#include <iostream>

RandomGenerateClass::RandomGenerateClass(QObject* parent) : QObject{ parent }
{
}

void RandomGenerateClass::generateRandom(const int& randomCount)
{
    QElapsedTimer timer;
    timer.start();
    std::vector<int> randomVector;
    std::random_device seed;                               // 真随机数生成器，得到随机数种子
    std::mt19937 gen(seed());                              // 伪随机数生成引擎
    std::uniform_int_distribution distribution(0, 100000); // 分布器
    for (int i = 0; i < randomCount; i++)
    {
        randomVector.push_back(distribution(gen));
    }
    int millisecond = timer.elapsed();
    std::cout << "生成" << randomCount << "用时" << millisecond << "毫秒" << std::endl;
    emit sendVector(randomVector);
}


